package org.seedframework.sharding.mybatis;


import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.plugin.Interceptor;
import org.seedframework.sharding.springglue.ShardingAutoConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnSingleCandidate;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.Lazy;

@Slf4j
@org.springframework.context.annotation.Configuration
@ConditionalOnSingleCandidate(ShardingAutoConfiguration.class)
@AutoConfigureAfter(ShardingAutoConfiguration.class)
@Import(ExecutorInterceptor.class)
public class MyBatisScatterAutoConfiguration {

    @Bean
    public Interceptor interceptor(){
        return new ExecutorInterceptor();
    }

    @Bean
    public MapperFactoryScatterBeanAware mapperFactoryScatterBeanAware(){
        return new MapperFactoryScatterBeanAware();
    }

    @Bean
    public MapperFactoryDoubleWriteBeanAware mapperFactoryDoubleWriteBeanAware(){
        return new MapperFactoryDoubleWriteBeanAware();
    }
}
